module dungeon.race;

import nade.ast;
import nade.loader;
import nade.sprite;

import dungeon.game;
import dungeon.stats;


class Race {
	this(Game game)
	{
		_game = game;
		_statsModified = new Stats();
	}

	string id() { return _id; }
	string name() { return _name; }
	string description() { return _description; }
	Sprite sprite(string className) { return _sprites[className]; }
	Stats statsModified() { return _statsModified; }

	protected {
		Game			_game;
		string			_id, _name;
		string			_description = "";

		Sprite[string]	_sprites;

		uint			_hitDice;
		Stats			_statsModified;
	}

	static void install()
	{
		Loader!(Race).add("name",
			(ref Race race, AST ast, Object[string] state)
			{
				race._id = ast[0].as!string;
				race._name = ast[1].as!string;
				race._game.addRace(race);
			}
		);

		Loader!(Race).add("class",
			(ref Race race, AST ast, Object[string] state) { race._sprites[ast[0].as!string] = new Sprite("Textures\\Sprites\\" ~ ast[1].as!string ~ ".bmp"); }
		);

		Loader!(Race).add("description",
			(ref Race race, AST ast, Object[string] state) { race._description = ast[0].as!string; }
		);

		Loader!(Race).add("hitDice",
			(ref Race race, AST ast, Object[string] state) { race._hitDice = ast[0].as!uint; }
		);

		Loader!(Race).add("mod",
			(ref Race race, AST ast, Object[string] state) { race._statsModified.add(ast[0].as!string, ast[1].as!real); }
		);
	}
}
